<%@ Page Language="C#" MasterPageFile="~/MasterDefault.master" AutoEventWireup="True"
    Inherits="TeamTime.TN5YProjectsForm" Title="Team Time - Projects"
    StylesheetTheme="Default" CodeBehind="TN5YProjectsForm.aspx.cs" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register Src="TN5YProjectFormControl.ascx" TagName="TN5YProjectFormControl" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <asp:ScriptManager runat="server" ID="ScriptManager1" EnablePartialRendering="true">
        <Services>
            <asp:ServiceReference Path="AutoComplete.asmx" />
        </Services>
    </asp:ScriptManager>
    <clib:UpdatePanelExtender runat="server" ID="UpdatePanelExtender1" UpdateMode="Conditional">
        <ContentTemplate>
            <h3>
                Projects &nbsp; &nbsp;<asp:Button runat="server" ID="btnAddNew" Text="Add New"
                    OnClick="btnAddNew_Click" CausesValidation="False" />
            </h3>
            <asp:Button runat="server" ID="btnAddDummy" Text="Add New" Visible="true" Style="display: none;" />
            <clib:ModalPopupPanel runat="server" ID="popUp1" TargetControlID="btnAddDummy" Width="600"
                Title="Projects">
                <uc1:TN5YProjectFormControl ID="TN5YProjectFormControl1" runat="server" 
                    OnSaveClicked="TN5YProjectFormControl1_SaveClicked" />
            </clib:ModalPopupPanel>
            <asp:Panel ID="pnlSearch" runat="server" DefaultButton="btnSearch">
                <table id="tblHead" cellspacing="0" cellpadding="1" border="0" runat="server">
                    <tr>
                        <td>
                            Search for&nbsp;
                        </td>
                        <td>
                            <asp:TextBox ID="txtSearchFor" runat="server" MaxLength="100" Width="150px"></asp:TextBox>
                        </td>
                        <td>
                            Search in details&nbsp;
                        </td>
                        <td>
                            <asp:CheckBox ID="chkSearchDetails" runat="server" Visible="true" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td>
                            Company
                        </td>
                        <td>
                            <asp:TextBox ID="txtCompanyNameSearch" runat="server" Width="200px"></asp:TextBox>
                            <ajaxToolkit:AutoCompleteExtender ID="extCompanyNameSearch" runat="server" EnableCaching="true"
                                MinimumPrefixLength="1" OnClientPopulated="hide1" OnClientPopulating="show1"
                                ServiceMethod="getCompanies" ServicePath="AutoComplete.asmx" SkinID="AutoCompleteExtender"
                                TargetControlID="txtCompanyNameSearch" />
                            <img id="imgProg1" src="App_Themes/Default/Images/ajaxloader.gif" alt="prog" style="visibility: hidden;" />

                            <script type="text/javascript">
                                function show1() {
                                    var ctrlid = 'imgProg1';
                                    document.getElementById(ctrlid).style.visibility = 'visible';
                                }
                                function hide1() {
                                    var ctrlid = 'imgProg1';
                                    document.getElementById(ctrlid).style.visibility = 'hidden';
                                }
                            </script>

                        </td>
                        <td>
                            Status
                        </td>
                        <td>
                            &nbsp;
                            <asp:DropDownList ID="ddlStatus" runat="server" Enabled="false">
                                <asp:ListItem>All</asp:ListItem>
                                <asp:ListItem>Followup</asp:ListItem>
                            </asp:DropDownList>
                        </td>
                       
                    </tr>
                    <tr id="trDates" runat="Server" visible="true">
                        <td style="width: 105px">
                            From Date
                        </td>
                        <td>
                            <clib:TextBoxCalendar ID="txtFromDate" runat="server" EnableViewState="true" ClearText=" ">
                            </clib:TextBoxCalendar>
                        </td>
                        <td>
                            To Date
                        </td>
                        <td>
                            <clib:TextBoxCalendar ID="txtToDate" runat="server" EnableViewState="true" ClearText=" ">
                            </clib:TextBoxCalendar>
                        </td>
                        <td>
                            <asp:Button ID="btnSearch" runat="server" CausesValidation="False" OnClick="btnSearch_Click"
                                Text="Search &gt;&gt;" />
                        </td>
                    </tr>
                </table>
            </asp:Panel>
            <br />
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" SkinID="GridView"
                AllowPaging="True" PageSize="20" AllowSorting="True" DataKeyNames="ID" OnPageIndexChanging="GridView1_PageIndexChanging"
                OnRowCommand="GridView1_RowCommand" OnRowDeleting="GridView1_RowDeleting">
                <Columns>
                    <asp:TemplateField HeaderText="" SortExpression="ID">
                        <ItemTemplate>
                            <asp:LinkButton ID="lnkID" runat="server" CausesValidation="false" CommandName="Select"
                                Text="Edit" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.ID") %>'></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="CompanyName" HeaderText="Company Name" SortExpression="CompanyName">
                    </asp:BoundField>
                    <asp:BoundField DataField="ProjectName" HeaderText="Project Name" SortExpression="ProjectName">
                    </asp:BoundField>
                    <asp:BoundField DataField="Category" HeaderText="Category" SortExpression="Category">
                    </asp:BoundField>
                    <asp:BoundField DataField="Priority" HeaderText="Priority" SortExpression="Priority">
                    </asp:BoundField>
                    <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status"></asp:BoundField>
                    <asp:BoundField DataField="Begin" HeaderText="Begin" SortExpression="Begin" DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false"></asp:BoundField>
                    <asp:BoundField DataField="End" HeaderText="End" SortExpression="End" DataFormatString="{0:yyyy/MM/dd}" HtmlEncode="false"></asp:BoundField>
                    <asp:BoundField DataField="Budget" HeaderText="Budget" SortExpression="Budget"></asp:BoundField>
                    <asp:BoundField DataField="PONumber" HeaderText="PONumber" SortExpression="PONumber">
                    </asp:BoundField>
                    <asp:BoundField DataField="Notes" HeaderText="Notes" SortExpression="Notes"></asp:BoundField>
                </Columns>
                <EmptyDataTemplate>
                    No records found</EmptyDataTemplate>
                <PagerTemplate>
                    <table width="100%">
                        <tr>
                            <td style="text-align: left; font-size: 11px; width: 100px;">
                                Page
                                <asp:Label ID="lblPageIndex" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                of
                                <asp:Label ID="lblPageCount" runat="server" Text='<%# ((GridView)Container.Parent.Parent).PageCount  %>' />
                            </td>
                            <td style="text-align: center; font-size: 11px;">
                                <asp:Panel ID="pnlPager" runat="server" DefaultButton="lnkGo">
                                    <asp:LinkButton ID="lnkFirst" runat="server" CausesValidation="False" CommandArgument="First"
                                        CommandName="Page" Text="Page 1" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkPrev" runat="server" CausesValidation="False" CommandArgument="Prev"
                                        CommandName="Page" Text="<< Prev" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkNext" runat="server" CausesValidation="False" CommandArgument="Next"
                                        CommandName="Page" Text="Next >>" />&nbsp;&nbsp;
                                    <asp:LinkButton ID="lnkLast" runat="server" CausesValidation="False" CommandArgument="Last"
                                        CommandName="Page" Text='<%# "Page "+ ((GridView)Container.Parent.Parent).PageCount  %>' />&nbsp;&nbsp;&nbsp;
                                    <asp:TextBox ID="txtNewPageIndex" runat="server" Width="20px" Text='<%# ((GridView)Container.Parent.Parent).PageIndex + 1  %>' />
                                    <asp:LinkButton ID="lnkGo" runat="server" CausesValidation="False" CommandArgument="-1"
                                        CommandName="Page" Text="Go" /><!-- here set the CommandArgument of the Go Button to '-1' as the flag -->
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </PagerTemplate>
            </asp:GridView>
        </ContentTemplate>
    </clib:UpdatePanelExtender>
</asp:Content>
